package org.example.java.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * Java implementation of the Unix tail command
 */
public class Tail {

  static long sleepTime = 1000;

  public static void main(String[] args) throws IOException {

    BufferedReader input = new BufferedReader(new FileReader("data/test.txt"));
    String currentLine = null;

    while (true) {

      if ((currentLine = input.readLine()) != null) {
        System.out.println(currentLine);
        continue;
      }

      try {
        Thread.sleep(sleepTime);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        break;
      }

    }
    input.close();
  }
}
